import React from 'react'
import { Breadcrumb } from 'antd'
import withRouter from 'umi/withRouter'
import breadList from 'dic/breadList'

import './index.styl'

const { Item } = Breadcrumb

function Bread(props) {
  const { history: { location: { pathname } }, flag } = props
  const name = pathname.split('/')[pathname.split('/').length - 1]
  return (
    <div className="bread">
      <Breadcrumb separator='|'>
        {
          flag?
          <Item>{breadList[name][breadList[name].length - 1]}</Item>
          :
          breadList[name].length && breadList[name].map((item) => {
            return (
              <Item key={item}>
                {item}
              </Item>
            )
          })
        }
      </Breadcrumb>
    </div>
  )
}

Bread.propTypes = {
  //Todo.
}

export default withRouter(Bread)
